ForAll(TSource) Method

Task Parallel System.Threading

Invokes in parallel the specified action for each element in the source.

Namespace:  System.Linq
Assembly:  System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Sub ForAll(Of TSource) ( _
	source As ParallelQuery(Of TSource), _
	action As Action(Of TSource) _
)
C#
public static void ForAll<TSource>(
	ParallelQuery<TSource> source,
	Action<TSource> action
)

Parameters

source
Type: System.Linq..::.ParallelQuery<(Of <(TSource>)>)
The ParallelQuery<(Of <(TSource>)>) whose elements will be processed by action.
action
Type: System..::.Action<(Of <(TSource>)>)
An Action to invoke on each element.

Type Parameters

TSource
The type of elements of source.

Remarks

This is an efficient way to process the output from a parallelized query because it does not require a merge step at the end. However, order of execution is non-deterministic.

Exceptions

ExceptionCondition
System..::.ArgumentNullException source or action is a null reference (Nothing in Visual Basic).
System..::.AggregateException One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException The query was canceled.

See Also